<?php
/**
 * 统一入口地址
 * @author zhaorongwei
 * @date 2012-05-04
 */
require ('../runtime.php');

error_reporting(0);
//路由
$controller = 'index';
$action = 'index';

if(isset($_REQUEST['r']))
{
	$pathinfo = explode('/',request('r'));
	if(count($pathinfo) == 2)
	{
		$controller = strtolower($pathinfo[0]);
		//$controller = $pathinfo[0];
		$action = $pathinfo[1];
	}
	elseif(count($pathinfo) == 1)
	{
		$action = strtolower($pathinfo[0]);
	}
}
//暂时关闭权限控制,待项目进行是时再打开
if($action != 'login' && $action !='verify')
{
	if(!isLogin())
	{
		redirect('user/login');
	}
	$authModel = loadModel('auth');
	//获得用户授权的模块id和模块名,为在模块列表的时候控制做准备
	$QYUserAuth=$authModel->getAuthByUid(loginInfo('uid'));
	if(!$authModel->isAuthUser(loginInfo('uid'), $action))
	{
		ex('未授权');
	}
}
$class_path = ROOT.'/controllers/'.$controller.'.class.php';
if(!file_exists($class_path))
{
	ex('类不存在');
}

require $class_path;

$controller .= 'Controller';
$objController = new $controller();
$objController->$action();
